<template>
  <div class="changeLanguage">
    <p>{{ $t('message.hello') }}</p>
    <el-button>{{ $t('button.submit') }}</el-button>
    <el-select v-model="currentLocale" @change="changeLocale">
      <el-option label="English" value="en"></el-option>
      <el-option label="中文" value="zh"></el-option>
    </el-select>
  </div>
</template>

<script setup>
import { useI18n } from 'vue-i18n'
import { ref } from 'vue'

const { locale } = useI18n()

const changeLocale = (type) => {
  locale.value = type; // 直接设置 locale 的值
}

</script>

<style lang="scss" scoped>
.changeLanguage {
  display: flex;
  align-items: center;
  min-width: 400px; // 设置最小宽度，确保组件不会被挤压
  margin-left: 20px; // 增加左边距，为组件提供更多空间

  p {
    line-height: 100px;
    height: 100px;
  }

  .el-select {
    width: 200px;
  }
}
</style>
